package asteroids.expression;

import asteroids.*;
import asteroids.model.programs.Program;


public class GetYVelExpression extends NumericExpression {

	public GetYVelExpression(Expression exp) {
		super(exp);
		
	}

	
	public double getValue(Program program) {
		this.updateArguments(program);
		if (this.arg1 instanceof EntityExpression) {

			return ((EntityExpression) arg1).getValue(program).getVelocity().getY();
		}else if(this.arg1 instanceof Variable && ((Variable)this.arg1).getRef(program) instanceof EntityExpression){
			return ((FlyingObject)((Variable)arg1).getValue(program)).getVelocity().getY();
		}else{
			return 0.001;
		}
	
	}

}
